//
//  BaseTableViewController.m
//  UILbrary
//
//  Created by mac on 16/7/11.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "BaseTableViewController.h"
#import "UILbrary-Swift.h"
#import "ListViewVC.h"
#import "MYHeader.h"

@interface BaseTableViewController ()
@property (strong, nonatomic) IBOutlet UITableView *rootTableView;
@property (strong, nonatomic) NSArray *titleArr;//cell 标题
@property (strong, nonatomic) NSArray *datas;//cell 标题

@end

@implementation BaseTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.rootTableView.backgroundColor = [UIColor orangeColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSArray *)p_arrFromeJsonData
{
    return [ListViewVC arrFromJsonName:@"HomeListConfig"];
}

#pragma mark - Table view data source


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseTableViewControllerCell"];
    NSString *title = [NSString stringWithFormat:@"%ld_%@",indexPath.row + 1, self.datas[indexPath.row][ListViewVC_DATA_TITLE_KEY]];
    cell.textLabel.text = title;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.datas.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController *vc = [ListViewVC pushViewController:self.datas[indexPath.row]];
    [self.navigationController pushViewController:vc animated:YES];
}



- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50.0;
}

- (NSArray *)datas
{
    if (!_datas) {
        _datas = [self p_arrFromeJsonData];
    }
    return _datas;
}
@end
